package com.dgut.staffmodule.entity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "t_position")
public class Position {
	private Long id;// 职位id
	private String positionName;// 职称
	private Department department;// 职位与部门关系是多对一

	// private List<Staff> staffs = new ArrayList<Staff>();
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	@Column(nullable = false, unique = true)
	public String getPositionName() {
		return positionName;
	}

	@ManyToOne(cascade = CascadeType.ALL)
	public Department getDepartment() {
		return department;
	}

	/*
	 * //职位与员工的关系是一对多
	 * 
	 * @JsonIgnore
	 * 
	 * @OneToMany(cascade = CascadeType.ALL,mappedBy="position") public List<Staff>
	 * getStaffs() { return staffs; } public void setStaffs(List<Staff> staffs) {
	 * this.staffs = staffs; }
	 */
	public void setDepartment(Department department) {
		this.department = department;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setPositionName(String positionName) {
		this.positionName = positionName;
	}

	@Override
	public String toString() {
		return "Position [id=" + id + ", positionName=" + positionName + "]";
	}

}
